4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
11 // You must not remove this notice, or any other, from this software.
16 namespace Microsoft
.JScript
{
18 using Microsoft
.JScript
.Vsa
;
20 using System
.Reflection
;
22 internal sealed class WrappedNamespace
: ActivationObject
{
25 internal WrappedNamespace(String name
, VsaEngine engine
)
26 : this(name
, engine
, true) {
29 internal WrappedNamespace(String name
, VsaEngine engine
, bool AddReferences
)
33 this.isKnownAtCompileTime
= true;
34 if (name
.Length
> 0 && AddReferences
)
35 engine
.TryToAddImplicitAssemblyReference(name
);
38 public override MemberInfo
[] GetMember(String name
, BindingFlags bindingAttr
){
39 FieldInfo cachedfield
= (FieldInfo
)(this.name_table
[name
]);
40 if (cachedfield
!= null) return new MemberInfo
[]{cachedfield}
;
42 FieldAttributes attrs
= FieldAttributes
.Literal
;
43 String fullname
= this.name
== null || this.name
.Length
== 0 ? name
: this.name
+"."+name
;
45 if (this.name
!= null && this.name
.Length
> 0)
46 t
= this.engine
.GetClass(fullname
); //Packages will not have classes residing in the default name space
48 t
= this.engine
.GetType(fullname
);
49 if (t
!= null && !((Type
)t
).IsPublic
){
50 if ((bindingAttr
& BindingFlags
.NonPublic
) == 0)
53 attrs
|= FieldAttributes
.Private
;
56 if ((((ClassScope
)t
).owner
.attributes
&TypeAttributes
.Public
) == 0){
57 if ((bindingAttr
& BindingFlags
.NonPublic
) == 0)
60 attrs
|= FieldAttributes
.Private
;
64 if (this.parent
!= null && (bindingAttr
&BindingFlags
.DeclaredOnly
) == 0)
65 return this.parent
.GetMember(name
, bindingAttr
);
66 return new MemberInfo
[0];
69 JSGlobalField field
= (JSGlobalField
)this.CreateField(name
, attrs
, t
);
71 field
.type
= new TypeExpression(new ConstantWrapper(Typeob
.Type
, null));
72 this.name_table
[name
] = field
;
73 this.field_table
.Add(field
);
74 return new MemberInfo
[]{field}
;
77 public override String
ToString(){